<template>
    <el-dialog title="Stu" :visible.sync="isShow">
        <el-form :model="form">
          <el-form-item label="用户ID"  :label-width="formLabelWidth">
            <el-input v-model="uid" placeholder="用户ID" autocomplete="off"></el-input>
          </el-form-item>
            <el-form-item v-if="myshow" label="设备名称"  :label-width="formLabelWidth">
                <el-input v-model="form.equipmentName" placeholder="设备名称" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item v-if="myshow" label="设备类型" :label-width="formLabelWidth">
                <el-input v-model="form.equipmentType" placeholder="设备类型" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item v-if="myshow" label="运行状态" :label-width="formLabelWidth">
                <el-input v-model="form.alarmType" placeholder="运行状态"></el-input>
            </el-form-item>
            <el-form-item v-if="myshow" label="位置" :label-width="formLabelWidth">
                <el-input v-model="form.address" placeholder="位置"></el-input>
            </el-form-item>
            <el-form-item v-if="myshow" label="连接方式" :label-width="formLabelWidth">
                <el-input v-model="form.linkType" placeholder="连接方式"></el-input>
            </el-form-item>
            <el-form-item v-if="myshow" label="连接端口" :label-width="formLabelWidth">
                <el-input v-model="form.maintainPort" placeholder="连接端口"></el-input>
            </el-form-item>
            <el-form-item v-if="myshow" label="创建日期" :label-width="formLabelWidth">
              <el-col :span="11">
                  <el-date-picker
                      
                      :label-width="formLabelWidth"
                      v-model="form.gmtCreate"
                      type="datetime" style="width: 100%;"
                      placeholder="上次维护日期"
                      format="yyyy-MM-dd hh:mm:ss"
                      value-format='yyyy-MM-dd[T]hh:mm:ss'
                      align="right"
                      :picker-options="pickerOptions">
                  </el-date-picker>
              </el-col>
          </el-form-item>
            <el-form-item v-if="myshow" label="上次维护日期">
              <el-col :span="11">
                  <el-date-picker
                      
                      v-model="form.gmtModified"
                      type="datetime" style="width: 100%;"
                      placeholder="上次维护日期"
                      format="yyyy-MM-dd hh:mm:ss"
                      value-format='yyyy-MM-dd[T]hh:mm:ss'
                      align="right"
                      :picker-options="pickerOptions">
                  </el-date-picker>
              </el-col>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button @click="dialogFormVisible">取 消</el-button>
            <el-button type="primary" @click="commit">确 定</el-button>
        </div>
    </el-dialog>
</template>

<script>
    export default {
        props: ['isShow','editInfo','hoverEquipmentInfo'],
        data() {
            return {
              uid: 0,
              pickerOptions: {
              shortcuts: [{
                text: '今天',
                onClick(picker) {
                  picker.$emit('pick', new Date());
                }
              }, {
                text: '昨天',
                onClick(picker) {
                  const date = new Date();
                  date.setTime(date.getTime() - 3600 * 1000 * 24);
                  picker.$emit('pick', date);
                }
              }, {
                text: '一周前',
                onClick(picker) {
                  const date = new Date();
                  date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
                  picker.$emit('pick', date);
                }
              }]
            },
              form: {},
              formLabelWidth: '100px',
              myshow: false
            }
        },
        methods:{
            commit() {
                if (this.editInfo){
                    this.$emit('update1',this.form);
                }else {
                  this.$emit('commitUidAndAddress',this.form,this.uid)
                }
                this.close()
            },
            dialogFormVisible(){
                this.close()
            },
            close() {
                this.$emit('close')
            }
        },
        mounted() {
            // 父组件传参告诉子组件我需要你可以让用户操作数据   或开始执行另一个方法
          this.form = JSON.parse(JSON.stringify(this.hoverEquipmentInfo))
          if(this.editInfo) {
            this.myshow = true
          }
          else {
            this.myshow = false
          }
            console.log(this.form)
        }
    }
</script>

<style scoped>

</style>